import type { EnumApi } from '#/api/enum';

import { requestClient } from '#/api/request';

export namespace CheckPlanApi {
  export type Params = object;
  export interface GetCheckPlanReq {
    pageNum: number;
    pageSize: number;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date | null;
    remark: string;
    params: Params;
    planId: number;
    planCode: string;
    planName: string;
    planType: string;
    startDate: Date | null;
    endDate: Date | null;
    cycleType: string;
    cycleCount: number;
    status: EnumApi.MesOrderStatusEnum | null | string;
    attr1: null | string;
    attr2: null;
    attr3: number;
    attr4: number;
    rangePicker: [Date, Date];
  }
  export interface GetCheckPlanListResp {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取类型列表
export const getCheckPlanList = (params: CheckPlanApi.GetCheckPlanReq) =>
  requestClient.get<CheckPlanApi.GetCheckPlanListResp>(
    '/mes/dv/checkplan/list',
    {
      params,
    },
  );

// 修改保养项目设置
export const updateCheckPlan = (data: CheckPlanApi.Row) =>
  requestClient.put<CheckPlanApi.GetCheckPlanListResp>(
    '/mes/dv/checkplan',
    data,
  );

// 增加保养项目设置
export const addCheckPlan = (data: CheckPlanApi.Row) =>
  requestClient.post<CheckPlanApi.GetCheckPlanListResp>(
    '/mes/dv/checkplan',
    data,
  );

// 删除保养项目设置
export const deleteCheckPlan = (id: string) =>
  requestClient.delete<CheckPlanApi.GetCheckPlanListResp>(
    `/mes/dv/checkplan/${id}`,
  );
